﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace BugTracker.WebUX.WebCode
{
    public sealed class BTSecurity
    {
        public static string GetUserId()
        {
            return Membership.GetUser().ProviderUserKey.ToString();
        }

        public static string GetUserName()
        {
            return Membership.GetUser().UserName;
        }

        public static bool IsAuthenticated()
        {
            if (HttpContext.Current.User == null)
                return false;
            else if (HttpContext.Current.User.Identity.IsAuthenticated)
                return true;
            else
                return false;
        }

        public static bool IsInRole(string role)
        {
            if (HttpContext.Current.User != null)
            {
                if (HttpContext.Current.User.IsInRole(role))
                    return true;
                else
                    return false;
            }
            return false;
        }
    }
}